const app = getApp()

//部门、日期、会议地
function has_existsdata(depart, date, room){
  return new Promise((resolve, reject)=>{
    wx.request({
      url: app.globalData.serverUrl + '/get-abc/?depart=' + depart + "&date=" + date + '&room=' + room,
      success(res) {
        console.log('comm function',res.data.length)
        if (res.data.length > 0) {
          resolve(true)
        }
        else
        {
          resolve(false)
        }
      },
      fail(err){
        reject()
      }
    })
  })
}

//判断是上午，下午，全天
function get_time_flag(datetime,that) {
  let vars = []
  let result = '';
  vars = datetime.split('-');
  let n1 = parseInt(vars[0]);
  let n2 = parseInt(vars[1]);
  if (n1 < 13 && n2 <= 13) {
    result = '上午';
    // that.setData({
    //   cur_css: 'swdayView'
    // })
  } else if (n1 >= 13 && (n2 >= 13 && n2 <= 19)) {
    result = '下午'
    // that.setData({
    //   cur_css: 'xwdayView'
    // })
  }
  else if (n1 < 11 && n2 > 13) {
    result = '全天'
    // that.setData({
    //   cur_css: 'onedayView'
    // })
  }
  return result
}

module.exports = {
  get_time_flag: get_time_flag,
  has_existsdata: has_existsdata,
}